package cate.game.play.skill.active;

import cate.common.util.XT;
import cate.game.play.config.PlayCfgArgs;
import cate.game.play.fighter.Fighter;
import cate.game.play.proce.action.ctx.SkillActionCtx;

import java.util.List;

/**
 * 若目标处于【灼烧】或【焚烧】状态，则必定暴击，同时提升自身20%暴击伤害，并恢复自身等同本次伤害50%的生命值
 */
public class 剑斩阎罗命AH extends ActiveHandler{

	private List<String> buff标签;

	private double 恢复系数;

	//buff标签=灼烧#焚烧&恢复系数=5000
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		buff标签 = args.getStrList("buff标签");
		恢复系数 = args.getWDouble("恢复系数",0d);
	}

	@Override
	public void onSkillDone(SkillActionCtx action) {
		if (XT.isBlank(buff标签)) {
			return;
		}
		for (Fighter target : action.getTargets()) {
			if (target.buff.containTags(buff标签)) {
				double damage = action.getStat().getTotalSkillDamage(action.getActor().getPid(), target.getPid());
				if (damage > 0) {
					skill.owner.attr.passiveHeal(action, skill.owner, damage * 恢复系数);
				}
			}
		}
	}
}
